/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package org.jackysoft.entity;





import org.dom4j.Element;
import org.jackysoft.bean.define.EntitySchemas;

/**
 * 
 */



public class PermissionNode extends AbstractNode {
	// ~ Instance fields
	// ////////////////////////////////////////////////////////

	/**
	 * 
	 */
	private static final long serialVersionUID = -4200745318368811420L;
	protected RestrictionNode restriction;
	protected String name;

	// ~ Constructors
	// ///////////////////////////////////////////////////////////

	/**
     * 
     */
	public PermissionNode() {
	}

	public PermissionNode(Element element) {
		super(element);
	}

	@Override
	public Element asElement() {
		Element root = elementof("permission");
		attr(root, "name", name);
		return root;
	}

	// ~ Methods
	// ////////////////////////////////////////////////////////////////

	public String getName() {
		return name;
	}

	
	
	public RestrictionNode getRestriction() {
		return restriction;
	}

	@Override
	protected void init(Element root) {
		this.name = stringAttr(root, "name");
		this.restriction = childof(root, "restrict-to", RestrictionNode.class);
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setRestriction(RestrictionNode restriction) {
		this.restriction = restriction;
	}

	@Override
	public String tagName() {
		// TODO Auto-generated method stub
		return "permission";
	}

}
